package cn.edu.scau.cmi.dengzejun.chapter04;

public class Factorial {
	public static void main(String agr[]) {
		long n=1,sum=0;
		while (true) {
			if (sum>9876) {
				break;
			}else {
				long tempSum=1;
				for (int i=1;i<=n;i++) {
					tempSum*=i;
				}
				sum+=tempSum;
			}
			n++;
		}
		System.out.println(n-1);
	}
}
